package org.jcb.view;

import org.jcb.ChinoisActivity;
import org.jcb.R;
import org.jcb.dao.data.ChineseDatabase;
import org.jcb.dao.data.GlobalDAO;
import org.jcb.model.ChineseQuestionnaire;
import org.jcb.model.DataChineseLanguage;
import org.jcb.model.EndOfQuestionException;
import org.jcb.model.User;

import android.content.Context;
import android.media.MediaPlayer;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;

public class AdminView extends LinearLayout {
	Button buttonChoice, buttonReinitTables, buttonReadTables  ;
	ChinoisActivity chinoisActivity ;
	
	public AdminView(Context context) {
		super(context);
		this.chinoisActivity = (ChinoisActivity) context;
		LayoutInflater layoutInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		layoutInflater.inflate(R.layout.admin,this);
		buttonChoice  = (Button) findViewById(R.id.deleteQuizzResult);
		buttonReinitTables = (Button) findViewById(R.id.buttonReinitTables);
		buttonReadTables = (Button) findViewById(R.id.buttonReadTables);
		
			buttonChoice.setOnClickListener(new View.OnClickListener() {
		        public void onClick(View v) {
		        	ChinoisActivity.globalDAO.deleteQuizzResult(chinoisActivity.getUser()) ;
		        }
		    });	

			buttonReinitTables.setOnClickListener(new View.OnClickListener() {
		        public void onClick(View v) {
		        	ChinoisActivity.globalDAO.dropTable() ;
	    			ChinoisActivity.globalDAO.createTable() ;
		        }
		    });	

			buttonReadTables.setOnClickListener(new View.OnClickListener() {
		        public void onClick(View v) {
		        	ChinoisActivity.globalDAO.readTables() ;
	    			
		        }
		    });	
			

	}

	
	
}
